package com.taotao.manage.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.taotao.manage.pojo.ItemCat;
import com.taotao.manage.service.ItemCatService;
@Controller
@RequestMapping("/itemcat")
public class ItemCatController {
	@Autowired
	private ItemCatService itemCatService;
	/**
	 * 根据父节点查询
	 * @param parentId
	 * @return
	 */
	@RequestMapping(method=RequestMethod.GET)
public ResponseEntity<List<ItemCat>> queryItemByPaerId(@RequestParam(value="id",defaultValue="0") Long parentId){
		try {
			ItemCat record = new ItemCat();
			record.setParentId(parentId);
			record.setStatus(1);
			List<ItemCat> itemCats = this.itemCatService.queryByListWhere(record );
			return ResponseEntity.status(HttpStatus.OK).body(itemCats);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();		}
		//500
	return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
	
}
}
